home *** CD-ROM | disk | FTP | other *** search
/ Belgian Amiga Club - ADF Collection / BS1 part 05.zip / BS1 part 5 / PDraw3.0.adf / pdraw_rex.lzh / ScaleToSize.pdrx < prev    next >
Text File  |  1992-06-22  |  1KB  |  75 lines

  1. /*
  2. @N
  3. This Genie will scale the current selection to a user specified size.
  4. */
  5.  
  6. parse arg obj, nwidth, nheight
  7.  
  8. msg = PDSetup.rexx(2,0)
  9. units = getclip(pds_units)
  10. if msg ~= 1 then exit_msg(msg)
  11.  
  12. if obj = '' then
  13. do
  14.  obj = pdm_SelFirstObj()
  15.  if obj = 0 then
  16.  do
  17.   obj = pdm_ClickOnObj("Click on object to be scaled")
  18.   if obj = 0 then exit_msg()
  19.   call pdm_SelectObj(obj)
  20.  end
  21.  
  22.  objsize = pdm_GetObjVisSize()
  23.  width = word(objsize, 1)
  24.  height = word(objsize, 2)
  25.  
  26.  if units = 3 then
  27.  do
  28.   nwidth = pdm_ConvertUnits(1,3,nwidth)
  29.   width = pdm_ConvertUnits(1,3,width)
  30.  end
  31.  
  32.  
  33.  size = pdm_GetForm("Enter new dimensions..", 8, "Width:"width || '0a'x || "Height:"height)
  34.  if size = '' then exit_msg()
  35.  
  36.  parse var size nwidth '0a'x nheight
  37.  
  38.  if ~(datatype(nwidth, n) & datatype(nheight, n)) then
  39.   exit_msg("Invalid entry")
  40.  
  41.  if units = 3 then
  42.  do
  43.   nwidth = pdm_ConvertUnits(units, 1, nwidth)
  44.   nheight = pdm_ConvertUnits(units, 1, nheight)
  45.  end
  46.  
  47. end
  48. else
  49. do
  50.  objsize = pdm_GetObjVisSize()
  51.  width = word(objsize, 1)
  52.  height = word(objsize, 2)
  53. end
  54.  
  55. objpos = pdm_GetObjPosn(obj)
  56. left = word(objpos, 1)
  57. top  = word(objpos, 2)
  58.  
  59.  
  60. xscale = nwidth/width
  61. yscale = nheight/height
  62.  
  63. call pdm_ScaleObj(, xscale, yscale, left, top)
  64.  
  65. exit_msg()
  66.  
  67. exit_msg: procedure expose units
  68. do
  69.  parse arg message
  70.  
  71.  if message ~= "" then call pdm_Inform(1,message,)
  72.  call pdm_SetUnits(units)
  73.  exit
  74. end